import Main from '@/views/Main.vue'

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
    path: '/login',
    name: 'login',
    meta: {
        title: 'Login - 登录'
    },
    component: () => import('@/views/Login.vue')
}

export const page404 = {
    path: '/*',
    name: 'error-404',
    meta: {
        title: '404-页面不存在'
    },
    component: () => import('@/components/error-page/404.vue')
}

export const page403 = {
    path: '/403',
    meta: {
        title: '403-权限不足'
    },
    name: 'error-403',
    component: () => import('@//components/error-page/403.vue')
}

export const page500 = {
    path: '/500',
    meta: {
        title: '500-服务端错误'
    },
    name: 'error-500',
    component: () => import('@/components/error-page/500.vue')
}


// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
    path: '/',
    name: 'otherRouter',
    redirect: '/home',
    component: Main,
    children: [
        {
            path: 'home',
            title: '首页',
            meta: {
                title: '工作台',
            },
            name: 'editGoods',
            component: () => import('@/components/home/home.vue')
        },
        {
            path: '/goods/add',
            title: '添加商品',
            meta: {
                title: '添加商品',
            },
            name: 'addGoods',
            component: () => import('@/views/goods/detail.vue')
        },
        {
            path: '/goods/edit/:id',
            title: '编辑商品',
            meta: {
                title: '编辑商品',
            },
            name: 'editGoods',
            component: () => import('@/views/goods/detail.vue')
        },
    ]
}

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
// 根据views里的文件会自动生成一个相应主路由，如一个模块有多个路由需自行填写
export const appRouter =[
    {
        path: '/page',
        name: 'page',
        title: '页面管理',
        icon: 'md-appstore',
        component: Main,
        children: [
            {
                path: '/page/homeBanner',
                meta: {
                    title: '首页轮播',
                },
                name: 'homeBanner',
                title: '首页轮播',
                component: () => import('@/views/page/index.vue')
            },
            {
                path: '/page/hotSearch',
                meta: {
                    title: '热门搜索',
                },
                name: 'hotSearch',
                title: '热门搜索',
                component: () => import('@/views/page/hotSearch.vue')
            },
        ]
    },
    {
        path: '/goods',
        name: 'goods',
        title: '商品管理',
        icon: 'md-appstore',
        component: Main,
        children: [
            {
                path: '/goods/goodsList',
                meta: {
                    title: '商品列表',
                },
                name: 'goodsList',
                title: '商品列表',
                component: () => import('@/views/goods/index.vue')
            },
            {
                path: '/goods/goodsCategory',
                meta: {
                    title: '商品分类',
                },
                name: 'goodsCategory',
                title: '商品分类',
                component: () => import('@/views/goods/category.vue')
            },
        ]
    },
    {
        path: '/video',
        name: 'video',
        title: '视频管理',
        icon: 'md-appstore',
        component: Main,
        children: [
            {
                path: '/video/videoList',
                meta: {
                    title: '视频列表',
                },
                name: 'videoList',
                title: '视频列表',
                component: () => import('@/views/video/index.vue')
            },
            {
                path: '/video/videoCategory',
                meta: {
                    title: '视频分类',
                },
                name: 'videoCategory',
                title: '视频分类',
                component: () => import('@/views/video/category.vue')
            },
        ]
    },
    {
        path: '/order',
        name: 'order',
        title: '订单管理',
        icon: 'md-appstore',
        component: Main,
        children: [
            {
                path: '/order/orderList',
                meta: {
                    title: '订单列表',
                },
                name: 'orderList',
                title: '订单列表',
                component: () => import('@/views/order/index.vue')
            },
        ]
    },
    {
        path: '/user',
        name: 'user',
        title: '用户管理',
        icon: 'md-appstore',
        component: Main,
        children: [
            {
                path: '/user/userList',
                meta: {
                    title: '用户列表',
                },
                name: 'userList',
                title: '用户列表',
                component: () => import('@/views/user/index.vue')
            },
        ]
    },
    {
        path: '/money',
        name: 'money',
        title: '资金管理',
        icon: 'md-appstore',
        component: Main,
        children: [
            {
                path: '/money/cashWithdrawal',
                meta: {
                    title: '提现申请',
                },
                name: 'cashWithdrawal',
                title: '提现申请',
                component: () => import('@/views/money/index.vue')
            },
        ]
    },
    {
        path: '/admin',
        name: 'admin',
        icon: 'ios-pricetags',
        title: '后台管理',
        component: Main,
        children: [
            {
                path: 'admin',
                meta: {
                    title: '管理员设置',
                },
                name: 'admin',
                title: '管理员设置',
                component: () => import('@/views/admin/index.vue')
            },
        ]
    }]

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
    loginRouter,
    otherRouter,
    ...appRouter,
    page500,
    page403,
    page404,
]

